<template>
  <view class="list">
    <u-list style="height: 100% !important;" :refresher-enabled="refresherEnabled" :scrollTop="scrollTop" :enableFlex="enableFlex"
      @scrolltolower="scrolltolower" @scrolltoupper="scrolltoupper"
      @refresherrefresh="refresherrefresh" :refresher-triggered="refresherTriggered2"
      @refresherrestore="refresherrestore"
      >
      <slot></slot>
      <u-loadmore v-if="status" :status="status" />
    </u-list>
  </view>
</template>

<script>
  import UList from '../../uni_modules/uview-ui/components/u-list/props.js'
  export default {
    props: {
      ...UList.props,
      status: {
        type: String,
        require: false,
        // validator(val) {
        //     return ['loadmore', 'loading', 'nomore'].includes(val)
        // }
      },
      enableFlex: {
        type: Boolean,
        default: true
      }
    },
    data() {
      return {
        oldScrollTop: 0,
        timer: null,
        flag: false,
        refresherTriggered2: false
      }
    },
    methods: {
      scrolltoupper(e) {
        console.log('scrolltoupper', e)
      },
      scrolltolower() {
        console.log('scrolltolower')
        this.$emit('scrolltolower')
      },
      refresherrefresh() {
        this.refresherTriggered2 = true
        console.log(this.refresherTriggered)
        this.$emit('refresherrefresh')
      },
      refresherrestore() {
        console.log(this.refresherTriggered)
        console.log('refresherrestore')
        this.$emit('refresherrestore')
      },
      closeRefresh() {
        setTimeout(() => {
          this.refresherTriggered2 = false
        }, 500)
        this.$emit('closeRefresh')
      }
    },
    created() {
      console.log(this.$attrs)
      console.log(this.$props)
    }
  }
</script>

<style lang="scss">
  .list{
    height: 100% !important;
    overflow: hidden;
    flex: 1;
  }
  ::v-deep scroll-view {
    // flex: 1;
    // overflow: hidden;
    // padding-bottom: 20rpx;
    // box-sizing: border-box;
    height: 100% !important;
  }
</style>
